package com.patchmanage.back.controller;


import cn.hutool.core.lang.Dict;
import com.patchmanage.back.entity.CascadeConfiguration;
import com.patchmanage.back.result.Result;
import com.patchmanage.back.service.ICascadeConfigurationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huizhao
 * @since 2021-04-17
 */
@Api(value = " 级联配置 controller", tags = {"级联配置 Api"})
@RestController
@RequestMapping("/back/cascadeconfiguration")
public class CascadeConfigurationController {

    @Autowired
    private ICascadeConfigurationService cascadeConfigurationService;

    /**
     * 获取级联配置接口
     *
     * @param dict
     * @return
     */
    @ApiOperation(value = "获取级联配置更新接口", notes = "获取级联配置更新接口")
    @RequestMapping(value = "getById", method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer", paramType = "body")
    })
    public Result<CascadeConfiguration> getById(@ApiIgnore @RequestBody Dict dict) {
        return Result.success(cascadeConfigurationService.getById(dict.getInt("id")));
    }


    /**
     * 新增级联配置更新接口
     * @param cascadeConfiguration
     * @return
     */
    @ApiOperation(value = "新增级联配置更新接口", notes = "新增级联配置更新接口")
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    public Result<Boolean> saveOrUpdate(@RequestBody CascadeConfiguration cascadeConfiguration){
        return Result.success(cascadeConfigurationService.saveOrUpdate(cascadeConfiguration));
    }

}
